import Mock from 'mockjs'
// 字符串，标题，句子，段落的方法
// const data=Mock.mock({
//     'string|4':'ahah'
// })
const data=Mock.mock({
    'string':'@cword(3,10)',//字符串
    'title':'@ctitle(3,10)',//标题
    'sentence':'@csentence(3,10)',//句子·
    'number1|1-100':1,//数字
    'id':'@increment(1)',//单调递增的ID值
    'name':'@cname()',//名字
    'idCard':'@id()',//身份证
    'address':'@city(true)',//地址
    'imgs':"@image('300x200','#ffa093','#ggo344','png','kunkun')",//图片
    'datas':'@date(yyyy-mm-dd hh:mm:ss)'//出生日期
})
const data1 = Mock.mock({
    'list|8-20':[
        {
     'name':'@cname()',
    'idCard':'@id()',
    'address':'@city(true)',//住址，true表示
    'datas':'@date(yyyy-mm-dd hh:mm:ss)',
     }
    ]
})


const getQuery = (url,name)=>{
    console.log(url)


}
Mock.mock(/\/api\/news/,'get',(options)=>{
    // 正则匹配借口
    console.log(options)
    const pageindex=getQuery(options.url,'pageindex')
    const pagesize= getQuery(options.url,'pagesize')
    

    return{
        status:200,
        message:'获取成功',
        list:data1
    }
})

Mock.mock('/api/news1','post',(options)=>{
    console.log(options)
    return{
        status:200,
        message:'获取成功',
        list:data1,
        total:data1.length,

    }
})
console.log(Mock,data,data1)

